package main

import (
	"fmt"
	userService "test/proto/userServer"

	"google.golang.org/protobuf/proto"
)

func main() {

	// fmt
	fmt.Println("....")
	u := &userService.Userinfo{
		Username: "张三",
		Age:      20,
		Hobby:    []string{"吃饭", "玩游戏"},
	}
	fmt.Println(u)
	userName := u.GetUsername()
	fmt.Println(userName)
	fmt.Println(u.GetType())

	// protobuf序列化
	data, _ := proto.Marshal(u)
	fmt.Println(data)

	// protobuf反序列
	userinfo := userService.Userinfo{}
	proto.Unmarshal(data, &userinfo)
	fmt.Printf("%#v", userinfo)
}
